#!/bin/ksh

##################################################
# name: S20jenkins
# purpose: script that will start or stop jenkins
##################################################


case "$1" in
start )
        TERM=ansi su - {{user}} -c 'ulimit -c 0; \
              export jenkins_log_file="/home/{{user}}/jenkins_console.log"
              export PATH=/opt/freeware/bin/ccache:/usr/java71_64/jre/bin:$PATH; \
              export HOME=/home/{{user}}; \
              export NODE_TEST_DIR=$HOME/tmp; \
              export NODE_COMMON_PIPE="$HOME/test.pipe"; \
              export OSTYPE=AIX61; \
              export JOBS=4; \
              export GIT_SSL_CAINFO="$HOME/ca-bundle.crt"; \
              export SSL_CERT_FILE="$HOME/ca-bundle.crt"; \
        java -Xmx128m -Dorg.jenkinsci.plugins.gitclient.Git.timeOut=30 -jar "$HOME/slave.jar" \
          -secret {{secret}} \
          -jnlpUrl https://ci.nodejs.org/computer/{{id}}/slave-agent.jnlp >$jenkins_log_file 2>&1 &'
        ;;
stop )
        ;;
* )
        echo "Usage: $0 (start | stop)"
        exit 1
esac
